﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Internal/Internal.Master" AutoEventWireup="true"
    CodeBehind="VesselManagement.aspx.cs" Inherits="Landscape.WebApp.Internal.Admin.VesselManagement" 
    Theme="Internal" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript" src="../../Scripts/ModuleMethods/VesselManagement.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <telerik:RadToolBar ID="rtbModuleActions" runat="server" Width="100%" EnableShadows="True"
        OnClientButtonClicked="rtbModuleActions_OnClientButtonClicked">
        <Items>
            <telerik:RadToolBarButton runat="server" CommandName="LIST" ImageUrl="~/Images/Search.png"
                Text="Search" CheckOnClick="True" ImagePosition="AboveText">
            </telerik:RadToolBarButton>
            <telerik:RadToolBarButton runat="server" CommandName="NEW" ImageUrl="~/Images/Write.png"
                Text="New" CheckOnClick="True" ImagePosition="AboveText">
            </telerik:RadToolBarButton>
            <telerik:RadToolBarButton runat="server" CommandName="SAVE" ImageUrl="~/Images/Floppy.png"
                Text="Save" CheckOnClick="True" ImagePosition="AboveText">
            </telerik:RadToolBarButton>
            <telerik:RadToolBarButton runat="server" CommandName="DELETE" ImageUrl="~/Images/Delete_32x32.png"
                Text="Delete" CheckOnClick="True" ImagePosition="AboveText">
            </telerik:RadToolBarButton>
        </Items>
    </telerik:RadToolBar>
    <telerik:RadTabStrip ID="rtsVesselManagement" runat="server" MultiPageID="RadMultiPage1"
        SelectedIndex="0">
        <Tabs>
            <telerik:RadTab runat="server" Owner="RadTabStrip1" Text="Search Results" PageViewID="RadPageView1">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Owner="RadTabStrip1" Text="Vessel Details" PageViewID="RadPageView2"
                Selected="True">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Owner="RadTabStrip1" Text="Vessel Documents" PageViewID="RadPageView3">
            </telerik:RadTab>
            <telerik:RadTab runat="server" Owner="RadTabStrip1" Text="Vessel Machinery" PageViewID="RadPageView4"
                Selected="True">
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTabStrip>
    <div class="ContentTabBody">
        <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0">
            <telerik:RadPageView ID="RadPageView1" runat="server" Selected="true">
                <telerik:RadGrid ID="rgSearchResults" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                    CellSpacing="0" GridLines="None">
                    <ClientSettings>
                        <Selecting AllowRowSelect="True" />
                        <ClientEvents OnCommand="rgSearchResults_OnCommand" OnGridCreated="rgSearchResults_OnGridCreated"
                            OnRowDataBound="rgSearchResults_OnRowDataBound" />
                    </ClientSettings>
                    <MasterTableView>
                        <CommandItemSettings ExportToPdfText="Export to PDF" />
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                        <Columns>
                            <telerik:GridClientSelectColumn FilterControlAltText="Filter column column" UniqueName="column">
                            </telerik:GridClientSelectColumn>
                            <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter column1 column"
                                HeaderText="Name" UniqueName="column1">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ImoNumber" FilterControlAltText="Filter column2 column"
                                HeaderText="IMO Number" UniqueName="column2">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="CallSign" FilterControlAltText="Filter column3 column"
                                HeaderText="Call Sign" UniqueName="column3">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="InmarsatPhoneNo" FilterControlAltText="Filter column6 column"
                                HeaderText="Phone No (Inmarsat)" UniqueName="column6">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="EMail" FilterControlAltText="Filter column4 column"
                                HeaderText="E-Mail" UniqueName="column4">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="IsDisabled" FilterControlAltText="Filter column5 column"
                                HeaderText="Is Disabled" UniqueName="column5">
                            </telerik:GridBoundColumn>
                        </Columns>
                        <EditFormSettings>
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView><FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                </telerik:RadGrid>
            </telerik:RadPageView>
            <telerik:RadPageView ID="RadPageView2" runat="server">
                <table>
                    <tr style="vertical-align: top;">
                        <td>
                            <asp:HiddenField ID="hfVesselID" runat="server" />
                            <table>
                                <tr style="vertical-align: top;">
                                    <td>
                                        <asp:Label ID="Label1" runat="server" Text="Name :" SkinID="ContentLabel"></asp:Label>
                                    </td>
                                    <td>
                                        <telerik:RadTextBox ID="rtbxName" runat="server">
                                        </telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>
                                        <asp:Label ID="Label2" runat="server" Text="IMO Number :" SkinID="ContentLabel"></asp:Label>
                                    </td>
                                    <td>
                                        <telerik:RadTextBox ID="rtbxIMONumber" runat="server">
                                        </telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>
                                        <asp:Label ID="Label3" runat="server" Text="Call Sign :" SkinID="ContentLabel"></asp:Label>
                                    </td>
                                    <td>
                                        <telerik:RadTextBox ID="rtbxCallSign" runat="server">
                                        </telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>
                                        <asp:Label ID="Label5" runat="server" Text="Inmarsat Phone No :" SkinID="ContentLabel"></asp:Label>
                                    </td>
                                    <td>
                                        <telerik:RadTextBox ID="rtbxPhone" runat="server">
                                        </telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>
                                        <asp:Label ID="Label6" runat="server" Text="FAX :" SkinID="ContentLabel"></asp:Label>
                                    </td>
                                    <td>
                                        <telerik:RadTextBox ID="rtbxFax" runat="server">
                                        </telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>
                                        <asp:Label ID="Label7" runat="server" Text="Vessel EMail :" SkinID="ContentLabel"></asp:Label>
                                    </td>
                                    <td>
                                        <telerik:RadTextBox ID="rtbxEmail" runat="server">
                                        </telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>
                                        <asp:Label ID="Label8" runat="server" Text="Hull No :" SkinID="ContentLabel"></asp:Label>
                                    </td>
                                    <td>
                                        <telerik:RadTextBox ID="rtbxHullNo" runat="server">
                                        </telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>
                                        <asp:Label ID="Label9" runat="server" Text="Port of Registry :" SkinID="ContentLabel"></asp:Label>
                                    </td>
                                    <td>
                                        <telerik:RadTextBox ID="rtbxPortofRegistry" runat="server">
                                        </telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>
                                        <asp:Label ID="Label10" runat="server" Text="Flag :" SkinID="ContentLabel"></asp:Label>
                                    </td>
                                    <td>
                                        <telerik:RadTextBox ID="rtbxFlag" runat="server">
                                        </telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>
                                        <asp:Label ID="Label11" runat="server" Text="Classification Society :" SkinID="ContentLabel"></asp:Label>
                                    </td>
                                    <td>
                                        <telerik:RadTextBox ID="rtbxClassSociety" runat="server">
                                        </telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr style="vertical-align: top">
                                    <td>
                                        <asp:Label ID="Label4" runat="server" Text="Is Disabled :" SkinID="ContentLabel"></asp:Label>
                                    </td>
                                    <td>
                                        <asp:CheckBox ID="cbIsDisabled" runat="server" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </telerik:RadPageView>
            <telerik:RadPageView ID="RadPageView3" runat="server">
                <table>
                    <tr style="vertical-align: top;">
                        <td>
                            <asp:HiddenField ID="HiddenField1" runat="server" />
                            <table>
                                <tr style="vertical-align: top;">
                                    <td colspan="2">
                                        <asp:Label ID="Label12" runat="server" Text="Attach Document(s) :" SkinID="ContentHeading"></asp:Label>
                                        <hr />
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td colspan="2">
                                        <telerik:RadAsyncUpload ID="rauFileAttachments" runat="server" MaxFileInputsCount="5"
                                            MultipleFileSelection="Automatic" TargetFolder="~/TempFiles" UploadedFilesRendering="BelowFileInput"
                                            DisablePlugins="True">
                                        </telerik:RadAsyncUpload>
                                    </td>
                                </tr>
                                <tr style="vertical-align: top;">
                                    <td>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td rowspan="2" class="Seperator">
                        </td>
                        <td>
                            <table>
                                <tr>
                                    <td>
                                        <asp:Label ID="Label13" runat="server" Text="Current Document(s) :" SkinID="ContentHeading"></asp:Label>
                                        <hr />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <telerik:RadGrid ID="rgCurrentDocuments" runat="server" AllowPaging="True" CellSpacing="0"
                                            GridLines="None">
                                            <ClientSettings>
                                                <Selecting AllowRowSelect="True" />
                                            </ClientSettings>
                                            <MasterTableView>
                                                <CommandItemSettings ExportToPdfText="Export to PDF" />
                                                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                                                    <HeaderStyle Width="20px" />
                                                </RowIndicatorColumn>
                                                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                                                    <HeaderStyle Width="20px" />
                                                </ExpandCollapseColumn>
                                                <EditFormSettings>
                                                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                                    </EditColumn>
                                                </EditFormSettings>
                                            </MasterTableView><FilterMenu EnableImageSprites="False">
                                            </FilterMenu>
                                        </telerik:RadGrid>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </telerik:RadPageView>
            <telerik:RadPageView ID="RadPageView4" runat="server">
                <table>
                    <tr>
                        <td style="min-width: 200px">
                            <asp:Label ID="Label15" runat="server" Text="Machinery Template :" SkinID="ContentLabel"></asp:Label>
                        </td>
                        <td colspan="2">
                            <telerik:RadComboBox ID="rcbTemplates" runat="server" OnClientLoad="rcbTemplates_OnClientLoad">
                            </telerik:RadComboBox>
                        </td>
                    </tr>
                    <tr>
                        <td style="min-width: 200px">
                            <asp:Label ID="Label14" runat="server" Text="Current Machine Category :" SkinID="ContentHeading"></asp:Label>
                            <hr />
                        </td>
                        <td class="Seperator" rowspan="2">
                        </td>
                        <td>
                            <asp:Label ID="Label25" runat="server" Text="Vessel Machine Details" SkinID="ContentHeading"></asp:Label>
                            <hr />
                        </td>
                    </tr>
                    <tr style="vertical-align: top">
                        <td style="min-width: 200px">
                            <telerik:RadTreeView ID="rtvSystemsTree" runat="server" CheckBoxes="True" CheckChildNodes="True"
                                MaxDataBindDepth="5" TriStateCheckBoxes="True" OnClientNodeExpanded="rtvSystemsTree_OnClientNodeExpanded"
                                OnClientNodeClicking="rtvSystemsTree_OnClientNodeClicking" OnClientNodeChecked="rtvSystemsTree_OnClientNodeChecked"
                                OnClientContextMenuItemClicking="rtvSystemsTree_OnClientContextMenuItemClicking">
                                <ContextMenus>
                                    <telerik:RadTreeViewContextMenu ID="RadTreeViewContextMenu1" runat="server">
                                        <Items>
                                            <telerik:RadMenuItem runat="server" Text="Remove">
                                            </telerik:RadMenuItem>
                                        </Items>
                                    </telerik:RadTreeViewContextMenu>
                                </ContextMenus>
                            </telerik:RadTreeView>
                        </td>
                        <td>
                            <div id="macineDetails">
                                <telerik:RadTabStrip ID="rtsMechDetails" runat="server" MultiPageID="RadMultiPage2"
                                    Width="100%" SelectedIndex="0">
                                    <Tabs>
                                        <telerik:RadTab runat="server" Text="Machine Item Details" PageViewID="rpvSysDetails"
                                            Selected="True">
                                        </telerik:RadTab>
                                        <telerik:RadTab runat="server" Text="Machine Item Documents" PageViewID="rpvDocuments">
                                        </telerik:RadTab>
                                        <telerik:RadTab runat="server" Text="Jobs" PageViewID="rpvJob">
                                        </telerik:RadTab>
                                    </Tabs>
                                </telerik:RadTabStrip>
                                <telerik:RadMultiPage ID="RadMultiPage2" runat="server" Width="100%" SelectedIndex="0">
                                    <telerik:RadPageView runat="server" ID="rpvSysDetails">
                                        <div style="float: left">
                                            <table class="ContentTable">
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label26" runat="server" Text="Name :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblName" runat="server" Text="" SkinID="ContentText"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label27" runat="server" Text="Description :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblDesc" runat="server" Text="" SkinID="ContentText"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label28" runat="server" Text="Specifications :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblSpecs" runat="server" Text="" SkinID="ContentText"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label29" runat="server" Text="Type :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblType" runat="server" Text="" SkinID="ContentText"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label30" runat="server" Text="Is Business Critical :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblIsBizCritical" runat="server" Text="" SkinID="ContentText"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label31" runat="server" Text="Is Environmental Critical :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblEnvCritic" runat="server" Text="" SkinID="ContentText"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label32" runat="server" Text="Is Safety Critical :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblIsSafCritic" runat="server" Text="" SkinID="ContentText"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label33" runat="server" Text="Is Mandatory :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblIsMan" runat="server" Text="" SkinID="ContentText"></asp:Label>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                        <div style="float: left">
                                            <table class="ContentTable">
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label16" runat="server" Text="Tag No :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <telerik:RadTextBox ID="RadTextBox1" runat="server">
                                                        </telerik:RadTextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label17" runat="server" Text="Manuf. Name :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <telerik:RadTextBox ID="RadTextBox2" runat="server">
                                                        </telerik:RadTextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label18" runat="server" Text="Manuf. Serial No. :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <telerik:RadTextBox ID="RadTextBox3" runat="server">
                                                        </telerik:RadTextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label19" runat="server" Text="Manuf. Year :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <telerik:RadTextBox ID="RadTextBox4" runat="server">
                                                        </telerik:RadTextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label20" runat="server" Text="Specifications :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <telerik:RadTextBox ID="RadTextBox5" runat="server" TextMode="MultiLine">
                                                        </telerik:RadTextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label21" runat="server" Text="Count :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <telerik:RadTextBox ID="RadTextBox6" runat="server">
                                                        </telerik:RadTextBox>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label22" runat="server" Text="Running Hours :" SkinID="ContentLabel"></asp:Label>
                                                    </td>
                                                    <td>
                                                        <telerik:RadTextBox ID="RadTextBox7" runat="server">
                                                        </telerik:RadTextBox>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </telerik:RadPageView>
                                    <telerik:RadPageView runat="server" Width="100%" ID="rpvDocuments">
                                    </telerik:RadPageView>
                                    <telerik:RadPageView runat="server" ID="rpvJob" >
                                        <!--Planned Jobs Goes Here-->
                                        <table style="width: 100%">
                                            <tr>
                                                <td style="width: 250px">
                                                    <asp:Label ID="Label23" runat="server" Text="Add new planned jobs: " SkinID="ContentLabel"></asp:Label>
                                                </td>
                                                <td>
                                                    <asp:ImageButton ID="imgBtnAddPlannedJob" runat="server" ImageAlign="Middle" ImageUrl="~/Images/Add_Plus.png"
                                                        AlternateText="New planned job" OnClientClick="return loadAddPlannedJobsWindow()" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    <asp:Label ID="Label24" runat="server" Text="Current planned jobs: " SkinID="ContentHeading"></asp:Label><hr />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    <telerik:RadGrid ID="rgPlannedJobs" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                                        CellSpacing="0" GridLines="None">
                                                        <ClientSettings Selecting-AllowRowSelect="true">
                                                            <Selecting AllowRowSelect="True" />
                                                            <ClientEvents OnCommand="rgPlannedJobs_OnCommand" OnGridCreated="rgPlannedJobs_OnGridCreated"
                                                                OnRowDataBound="rgPlannedJobs_OnRowDataBound" />
                                                        </ClientSettings>
                                                        <MasterTableView>
                                                            <CommandItemSettings ExportToPdfText="Export to PDF" />
                                                            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                                                                <HeaderStyle Width="20px" />
                                                            </RowIndicatorColumn>
                                                            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                                                                <HeaderStyle Width="20px" />
                                                            </ExpandCollapseColumn>
                                                            <Columns>
                                                                <telerik:GridClientSelectColumn FilterControlAltText="Filter column column" HeaderText="#"
                                                                    UniqueName="column">
                                                                </telerik:GridClientSelectColumn>
                                                                <telerik:GridBoundColumn FilterControlAltText="Filter column4 column" HeaderText="Code"
                                                                    UniqueName="column4" DataField="Code">
                                                                </telerik:GridBoundColumn>
                                                                <telerik:GridBoundColumn FilterControlAltText="Filter column1 column" HeaderText="Title"
                                                                    UniqueName="column1" DataField="Title">
                                                                </telerik:GridBoundColumn>
                                                                <telerik:GridBoundColumn FilterControlAltText="Filter column2 column" HeaderText="Periodicity"
                                                                    UniqueName="column2" DataField="Periodicity2">
                                                                </telerik:GridBoundColumn>
                                                                <telerik:GridBoundColumn FilterControlAltText="Filter column3 column" HeaderText="Priority"
                                                                    UniqueName="column3" DataField="Priority">
                                                                </telerik:GridBoundColumn>
                                                                <telerik:GridBoundColumn FilterControlAltText="Filter column5 column" HeaderText="Is Released"
                                                                    UniqueName="column5" DataField="IsReleased">
                                                                </telerik:GridBoundColumn>
                                                                <telerik:GridBoundColumn FilterControlAltText="Filter column6 column" HeaderText="Released Date"
                                                                    UniqueName="column6" DataField="ReleasedDate2">
                                                                </telerik:GridBoundColumn>
                                                                <telerik:GridBoundColumn FilterControlAltText="Filter column7 column" HeaderText="Last Change Date"
                                                                    UniqueName="column7" DataField="UpdatedDate2">
                                                                </telerik:GridBoundColumn>
                                                                <telerik:GridBoundColumn FilterControlAltText="Filter column7 column" HeaderText="Last Changed By"
                                                                    UniqueName="column9" DataField="UpdatedBy2">
                                                                </telerik:GridBoundColumn>
                                                                <telerik:GridBoundColumn FilterControlAltText="Filter column8 column" HeaderText="Actions"
                                                                    UniqueName="column8">
                                                                </telerik:GridBoundColumn>
                                                            </Columns>
                                                            <EditFormSettings>
                                                                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                                                </EditColumn>
                                                            </EditFormSettings>
                                                        </MasterTableView>
                                                        <FilterMenu EnableImageSprites="False">
                                                        </FilterMenu>
                                                    </telerik:RadGrid>
                                                </td>
                                            </tr>
                                        </table>
                                    </telerik:RadPageView>
                                </telerik:RadMultiPage>
                            </div>
                        </td>
                    </tr>
                </table>
            </telerik:RadPageView>
        </telerik:RadMultiPage>
    </div>
    <telerik:RadWindow ID="rwAddPlannedJobs" runat="server" Modal="true" AutoSize="true"
        BackColor="#f5e6f034" Title="Add Planned Jobs" ShowContentDuringLoad="false"
        Behaviors="Resize, Close, Move, Reload" VisibleStatusbar="false" OnClientClose="rwAddPlannedJobs_OnClientClose">
    </telerik:RadWindow>
    <script type="text/javascript">

        function initVesselMngr() {
            var vslMngr = new VesselMgmt();
            vslMngr.NameCtrl = $find('<%=rtbxName.ClientID %>');
            vslMngr.IMONumCtrl = $find('<%=rtbxIMONumber.ClientID %>');
            vslMngr.CallSignCtrl = $find('<%=rtbxCallSign.ClientID %>');
            vslMngr.PhoneCtrl = $find('<%=rtbxPhone.ClientID %>');
            vslMngr.FaxCtrl = $find('<%=rtbxFax.ClientID %>');
            vslMngr.EmailCtrl = $find('<%=rtbxEmail.ClientID %>');
            vslMngr.HullCtrl = $find('<%=rtbxHullNo.ClientID %>');
            vslMngr.PortCtrl = $find('<%=rtbxPortofRegistry.ClientID %>');
            vslMngr.FlagCtrl = $find('<%=rtbxFlag.ClientID %>');
            vslMngr.ClassCtrl = $find('<%=rtbxClassSociety.ClientID %>');
            vslMngr.DisableCtrl = $get('<%=cbIsDisabled.ClientID %>');
            vslMngr.TemplateComboCtrl = $find('<%=rcbTemplates.ClientID %>');
            vslMngr.VesselTabStrip = $find('<%=rtsVesselManagement.ClientID %>');
            vslMngr.FileUploadCtrl = $find('<%=rauFileAttachments.ClientID %>');
            vslMngr.DocsGrid = $find('<%=rgCurrentDocuments.ClientID %>');
            vslMngr.CurrentSystemsTRVCtrl = $find('<%=rtvSystemsTree.ClientID %>');
            vslMngr.SearchGrid = $find('<%=rgSearchResults.ClientID %>');
            vslMngr.JobsGrid = $find('<%=rgPlannedJobs.ClientID %>');

            vslMngr.VesselItemDescription = $get('<%=lblDesc.ClientID %>');
            vslMngr.VesselItemIsBizCritical = $get('<%=lblIsBizCritical.ClientID %>');
            vslMngr.VesselItemIsEnvCritical = $get('<%=lblEnvCritic.ClientID %>');
            vslMngr.VesselItemIsMandatory = $get('<%=lblIsMan.ClientID %>');
            vslMngr.VesselItemIsSafetyCritical = $get('<%=lblIsSafCritic.ClientID %>');
            vslMngr.VesselItemName = $get('<%=lblName.ClientID %>');
            vslMngr.VesselItemSpecifications = $get('<%=lblSpecs.ClientID %>');
            vslMngr.VesselItemType = $get('<%=lblType.ClientID %>');

            return vslMngr;
        }

        function loadAddPlannedJobsWindow() {
            var currentVesselObject = MASTER_GetCurrentBusinessObject();

            if (MASTER_GetCurrentBusinessObject() != null) {
                var vslMgr = initVesselMngr();
                var systemID = vslMgr.GetSelectedVesselSystemID();
                if (systemID != null) {
                    var url = '<%=Page.ResolveClientUrl("~/Internal/InternalWindows.aspx") %>';
                    url += '?ctrl=ADDPMJ&VID=' + currentVesselObject.ID + '&SID=' + systemID;

                    $find('<%=rwAddPlannedJobs.ClientID %>').setUrl(url);
                    $find('<%=rwAddPlannedJobs.ClientID %>').show();
                }
                else {
                    N_NotifyMessage('Parent machine is not found !!!', 'Please select a parent machine to add its planned jobs.', 3);
                }
            }
            else {
                N_NotifyMessage('Vessel information not found !!!', 'Please select a vessel or create a vessel to add its planned jobs.', 3);
            }
            return false;
        }



        function rtbModuleActions_OnClientButtonClicked(sender, args) {
            processCommands(args.get_item().get_commandName());
            args.get_item().set_checked(false);
        }

        function rcbTemplates_OnClientLoad(sender, args) {
            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
            comboItem.set_text("-Select-");
            comboItem.set_value("0");
            sender.get_items().add(comboItem);

            Landscape.AdministrativeActions.GetTemplatesByName('', -1, -1, function (result, e) {
                for (var idx = 0; idx < result.length; idx++) {
                    comboItem = new Telerik.Web.UI.RadComboBoxItem();
                    comboItem.set_text(result[idx].Name);
                    comboItem.set_value(result[idx].ID);
                    sender.get_items().add(comboItem);
                }
            }, function (result, e) { N_NotifyMessage('Error !!!', result.get_message(), 2); });

            sender.get_items().getItem(0).select();
        }

        function rgPlannedJobs_OnGridCreated(sender, args) {
            sender.get_masterTableView().set_dataSource('');
            sender.get_masterTableView().dataBind();
        }

        function rwAddPlannedJobs_OnClientClose(sender, args) {
            var vslMgmt = initVesselMngr();
            var vslItemCode = vslMgmt.CurrentSystemsTRVCtrl.get_selectedNodes()[0].get_attributes().getAttribute('VsselItemCode');

            vslMgmt.LoadJobsByVesselItem(vslItemCode, 0, 10);
        }

        function rgPlannedJobs_OnCommand(sender, args) {

        }

        function rgPlannedJobs_OnRowDataBound(sender, args) {
            var cell = args.get_item().get_cell('column4');
            var anchor = String.format("<a href='#' onclick='return showJobDetails({0});'>{1}</a>", String.format("\"{0}\"", args.get_dataItem().ID), args.get_dataItem().Code);
            cell.innerHTML = anchor;

            var cell1 = args.get_item().get_cell('column5');
            cell1.innerHTML = (args.get_dataItem().IsReleased ? 'Yes' : 'No');

            if (!args.get_dataItem().IsReleased) {
                var cell2 = args.get_item().get_cell('column8');
                var anchor1 = String.format("<a href='#' onclick='return releaseJob({0});'><img src='{1}' alt='Release Job' style='border:0px'/></a>", String.format("\"{0}\"", args.get_dataItem().ID), "../../Images/001_06.png");
                anchor1 = anchor1 + String.format("<a href='#' onclick='return deleteJob({0});'><img src='{1}' alt='Delete Job' style='border:0px'/></a>", String.format("\"{0}\"", args.get_dataItem().ID), "../../Images/DeleteMessage.png");
                cell2.innerHTML = anchor1;
            }
        }

        function showJobDetails(jobId) {
            var currentVesselObject = MASTER_GetCurrentBusinessObject();

            if (MASTER_GetCurrentBusinessObject() != null) {
                var vslMgr = initVesselMngr();
                var systemID = vslMgr.GetSelectedVesselSystemID();
                if (systemID != null) {
                    var url = '<%=Page.ResolveClientUrl("~/Internal/InternalWindows.aspx") %>';
                    url += '?ctrl=ADDPMJ&VID=' + currentVesselObject.ID + '&SID=' + systemID + '&JID=' + jobId;

                    $find('<%=rwAddPlannedJobs.ClientID %>').setUrl(url);
                    $find('<%=rwAddPlannedJobs.ClientID %>').show();
                }
                else {
                    N_NotifyMessage('Parent machine is not found !!!', 'Please select a parent machine to add its planned jobs.', 3);
                }
            }
            else {
                N_NotifyMessage('Vessel information not found !!!', 'Please select a vessel or create a vessel to add its planned jobs.', 3);
            }
            return false;
        }

        function releaseJob(jobId) {
            N_ConfirmMessage('Do you want to release?', 'Releasing a job will prevent the users from updating the job details further. Do you want to release now?', 3, function () { proceedToRelease(jobId); }, null);
        }

        function proceedToRelease(jobID) {
            var vslMgmt = new initVesselMngr();
            vslMgmt.ReleaseJob(jobID);
        }

        function deleteJob(jobId) {
            N_ConfirmMessage('Do you want to delete?', 'Deleting a job will completly remove the job from the system. Do you want to delete now?', 3, function () { proceedToDelete(jobId); }, null);
        }

        function proceedToDelete(jobID) {
            var vslMgmt = new initVesselMngr();
            vslMgmt.DeleteJob(jobID);
        }

        function rgSearchResults_OnGridCreated(sender, args) {
            sender.get_masterTableView().set_dataSource('');
            sender.get_masterTableView().dataBind();
        }

        function rgSearchResults_OnCommand(sender, args) {
        }

        function rgSearchResults_OnRowDataBound(sender, args) {
            var cell = args.get_item().get_cell('column1');

            var anchor = "<a href='#' onclick='return loadVesselData(" + args.get_item().get_id().toString() + ");'>" + args.get_dataItem().Name + "</a>";
            cell.innerHTML = anchor;

            cell = args.get_item().get_cell('column5');
            anchor = (args.get_dataItem().IsDisabled ? 'Yes' : 'No');
            cell.innerHTML = anchor;
        }

        function processCommands(pCmdName) {
            switch (pCmdName) {
                case 'SAVE':
                    {
                        //performSave();
                        var vslMgr = initVesselMngr();
                        vslMgr.PerformSaveOperation();
                        break;
                    }

                case 'LIST':
                    {
                        //switchTab(0);
                        //performList();
                        var vslMgr = initVesselMngr();
                        vslMgr.PerformListOperation();
                        vslMgr.SelectTabByIndex(0);
                        break;
                    }

                case 'DELETE':
                    {
                        performDelete();
                        break;
                    }

                case 'NEW':
                    {
                        //switchTab(1);
                        //loadCurrentVesselData(null);
                        var vslMgr = initVesselMngr();
                        vslMgr.LoadCurrentVesselData(null);
                        vslMgr.SelectTabByIndex(1);
                        break;
                    }
            }
        }


        function loadVesselData(pDataItem) {
            var rgSearchResults = $find('<%=rgSearchResults.ClientID %>');
            var dataItem = null;
            for (var idx = 0; idx < rgSearchResults.get_masterTableView().get_dataItems().length; idx++) {
                if (rgSearchResults.get_masterTableView().get_dataItems()[idx].get_id() == pDataItem.id) {
                    dataItem = rgSearchResults.get_masterTableView().get_dataItems()[idx].get_dataItem();
                    break;
                }
            }
            var vslMgr = initVesselMngr();
            vslMgr.LoadCurrentVesselData(dataItem);

            return false;
        }


        function loadTemplateMachines(pTemplateID) {
            Landscape.AdministrativeActions.GetTemplateMachineryListByParentEx(pTemplateID, null, MASTER_GetCurrentBusinessObject().ID, function (result2, e) {
                addToTreeViewNode($find('<%=rtvSystemsTree.ClientID %>'), result2);
            }, function (result2, e) { N_NotifyMessage('Error !!!', result2.get_message(), 2); });
        }

        function addToTreeViewNode(pParentNode, pResultArray) {
            pParentNode.get_nodes().clear();
            if (pResultArray.length > 0) {
                for (var i = 0; i < pResultArray.length; i++) {
                    var node = new Telerik.Web.UI.RadTreeNode();
                    node.set_text(pResultArray[i].MachineItem.Name);
                    node.set_value(pResultArray[i].ID);
                    if (pResultArray[i].AttachedToVessel) {
                        node.set_imageUrl('<%=Page.ResolveClientUrl("~/Images/02.png") %>');
                        node.get_attributes().setAttribute('VsselItemCode', pResultArray[i].VesselItemID);
                    } else {
                        node.set_imageUrl('<%=Page.ResolveClientUrl("~/Images/01.png") %>');
                    }
                    node.get_attributes().setAttribute('dataitem', pResultArray[i]);
                    var node = pParentNode.get_nodes().add(node);
                }
            }
        }

        function rtvSystemsTree_OnClientNodeExpanded(sender, args) {

        }

        function rtvSystemsTree_OnClientNodeClicking(sender, args) {
            var node = args.get_node();

            var vslItem = node.get_attributes().getAttribute('VsselItemCode');
            if (vslItem != null) {

                var vslMgmt = initVesselMngr();
                vslMgmt.LoadVesselItemDetails(node.get_attributes().getAttribute('VsselItemCode'));
            }
            else {
                var msg = '<b>' + node.get_text() + '</b> not currently not assigned to this vessel. Do you want to do it now?';
                N_ConfirmMessage('Not Assigned !!!', msg, 3, function () { var vslMgmt = initVesselMngr(); vslMgmt.AssignItemToVessel(args.get_node()); }, null);
                args.set_cancel(true);
            }
        }



        function rtvSystemsTree_OnClientNodeChecked(sender, args) {
            var currentVesselObject = MASTER_GetCurrentBusinessObject();

            if (args.get_node().get_nodes().get_count() == 0) {
                //Add nodes
                Landscape.AdministrativeActions.GetTemplateMachineryListByParentEx(currentVesselObject.TemplateID, args.get_node().get_value(), MASTER_GetCurrentBusinessObject().ID, function (result, e) {
                    addToTreeViewNode(args.get_node(), result);
                    args.get_node().expand();

                    for (var idx = 0; idx < args.get_node().get_nodes().get_count(); idx++) {
                        args.get_node().get_nodes().getNode(idx).check();
                        rtvSystemsTree_OnClientNodeChecked(sender, new Telerik.Web.UI.RadTreeNodeEventArgs(args.get_node().get_nodes().getNode(idx), args.get_domEvent()));
                    }

                }, function (result2, e) { N_NotifyMessage('Error !!!', result.get_message(), 2); });
            }
        }

        function rtvSystemsTree_OnClientContextMenuItemClicking(sender, args) {
            var vslObject = MASTER_GetCurrentBusinessObject();
            if (vslObject.IsReleased != true) {
                N_ConfirmMessage('Do you want to remove?', 'removing any item will completly remove selected item and its jobs along with all the constituents and their jobs from the system. Do you want to proceed?', 3, function () { proceedToRemoveItems(args.get_node().get_attributes().getAttribute('VsselItemCode')); }, null);
            }
            else {
                N_NotifyMessage('Cannot remove !!!', 'The vessel is released. You can remove or add items only through change requests.', 3);
            }
        }

        function proceedToRemoveItems(vesselItemCode) {
            var vslMgmt = initVesselMngr();
            vslMgmt.RemoveVesselItem(vesselItemCode);
        }

    </script>
</asp:Content>
